﻿
wg_frame_bottom_view =
{
    inited_ = false;

    mainframe_id_ = 0;
    bottom_dlg_id_ = 0;
    bottom_panel_id_ = 0;
 
    bottom_operate_area_id_ = 0;
    bottom_downLoading_area_id_ = 0;
    bottom_helper_area_id_ = 0;

    MINI_MARGIN_CONTENT = 25;
    MAX_MAIN_WEB_WIDTH = 1200; 
    BOTTOM_BAR_HEIGHT = 60;
    color_text_ =  "0xA4A4A4";
    color_mode_ = MainCommon.color_mode.kDark;

    GAME_MAIN_TYPE_ENUM = {
        MMOG_GAME = 1,
        WEB_GAME = 2,
        CONSOLE_GAME = 3,
        MOBILE_GAME = 4
    };

    game_id_ = 0;
    game_main_type_ = 0;

    game_and_plugin_state_tbl_ = nil;

    WG_FRAME_BOTTOM_RES_CFG = {
        LIGHT = {
            BOTTOM_BG_COLOR = "COLOR:RGB:255,255,255",
            ASSIST_BTN_TXT_COLOR = "RGB:60,60,60",
            DOWNLOADING_TXT_COLOR = "RGB:112,112,112",
        };
        DARK = {
            BOTTOM_BG_COLOR = "COLOR:RGB:0,0,0",
            ASSIST_BTN_TXT_COLOR = "0xA4A4A4",
            DOWNLOADING_TXT_COLOR = "RGB:255,255,255",
        };
    };

    res_cfg_ = {};

    inner_log = function (msg, core_msg)
        base_utility.log(string.format("[wg_frame_bottom_view] %s", msg), core_msg);
    end;

    init = function()
        if wg_frame_bottom_view.inited_ then
            return;
        end;
        wg_frame_bottom_view.inited_ = true;

        wg_frame_bottom_view.mainframe_id_ = ui_utility.get_ctrl_id_by_cid(
                           CID_MAINFRAME_Dialog_MainFrame);
        wg_frame_bottom_view.bottom_dlg_id_ = ui_utility.get_ctrl_id_by_path(
                           wg_frame_bottom_view.mainframe_id_, 
                           "pnlClient\\Ctn_BottomBar\\Dlg_Bottom");
        wg_frame_bottom_view.bottom_panel_id_ = ui_utility.get_ctrl_id_by_path(
                           wg_frame_bottom_view.mainframe_id_, 
                           "pnlClient\\Ctn_BottomBar\\Dlg_Bottom\\FrameBottomCtn_Pnl");

        wg_frame_bottom_view.bottom_operate_area_id_ = ui_utility.get_ctrl_id_by_path(
                           wg_frame_bottom_view.bottom_dlg_id_,
                           "FrameBottomCtn_Pnl\\Ctn_BottomArea\\Bottom_Operate_Area");

        wg_frame_bottom_view.bottom_downLoading_area_id_ = ui_utility.get_ctrl_id_by_path(
                           wg_frame_bottom_view.bottom_dlg_id_,
                           "FrameBottomCtn_Pnl\\Ctn_BottomArea\\Bottom_DownLoading_Area");

        wg_frame_bottom_view.bottom_helper_area_id_ = ui_utility.get_ctrl_id_by_path(
                           wg_frame_bottom_view.bottom_dlg_id_,
                           "FrameBottomCtn_Pnl\\Ctn_BottomArea\\Bottom_Helper_Area");

        comm_center.reg_service("i_service_refresh_operate_menu", 
                                    wg_frame_bottom_view.on_refresh_operate_menu);

        comm_center.listen_broadcast("i_broadcast_game_protocol_update_suc", 
                                    wg_frame_bottom_view.on_game_protocol_update_suc);
        comm_center.listen_broadcast("MsgTGPConfigMgr_UpdateClientMode",
            "wg_frame_bottom_view.on_color_mode_update");
        wg_frame_bottom_view.res_cfg_ = wg_frame_bottom_view.WG_FRAME_BOTTOM_RES_CFG.DARK;

        local color_data_config = comm_center.call_service("SvrTGPConfigMgr_GetColorMode", {});
        if color_data_config ~= nil and color_data_config.color_mode ~=nil then
            local color_data_param = {color_mode = color_data_config.color_mode };
            wg_frame_bottom_view.color_mode_ = color_data_config.color_mode;
        end;
        if wg_frame_bottom_view.color_mode_ == MainCommon.color_mode.kLight then
            wg_frame_bottom_view.res_cfg_ = wg_frame_bottom_view.WG_FRAME_BOTTOM_RES_CFG.LIGHT;
        end;
        local color_data_param = {color_mode = wg_frame_bottom_view.color_mode_ };
        wg_frame_bottom_view.on_color_mode_update(color_data_param);
    end;

    show_bottom_panel = function(show)
        local color_data_config = comm_center.call_service("SvrTGPConfigMgr_GetColorMode", {});
        if color_data_config ~= nil and color_data_config.color_mode ~=nil then
            wg_frame_bottom_view.color_mode_ = color_data_config.color_mode;
        end;
        if wg_frame_bottom_view.color_mode_ == MainCommon.color_mode.kLight then
            wg_frame_bottom_view.res_cfg_ = wg_frame_bottom_view.WG_FRAME_BOTTOM_RES_CFG.LIGHT;
        end;
        local color_data_param = {color_mode = wg_frame_bottom_view.color_mode_ };
        wg_frame_bottom_view.on_color_mode_update(color_data_param);
        local ptr = ui_utility.get_ctrl_ptr_by_id(wg_frame_bottom_view.bottom_panel_id_);
        if show == true then
            if ptr ~= nil then
                ptr:Show(TRUE);
                wg_frame_bottom_view.set_bottom_bar_position(true);
            end
        else
            if ptr ~= nil then
                ptr:Show(FALSE);
            end
            progress_node_tips_area.hide_progress_node();
        end;
    end;

    is_visible = function()
        local ptr = ui_utility.get_ctrl_ptr_by_id(wg_frame_bottom_view.bottom_panel_id_);
        if ptr ~= nil and ptr:IsVisible() == TRUE then
            return true;
        end
        return false;
    end;

    set_bottom_bar_position = function(allow_delay_set)
        local pBtmDlg = ui_utility.get_ctrl_ptr_by_id(wg_frame_bottom_view.bottom_dlg_id_);
        if pBtmDlg ~= nil and pBtmDlg:IsVisible() == TRUE then
            local mainframe_ptr = ui_utility.get_ctrl_ptr_by_id(wg_frame_bottom_view.mainframe_id_);
            local width_mainframe = 0;
            local height_mainframe = 0;
            if mainframe_ptr ~= nil then
                local rc_mainframe = mainframe_ptr:GetRectEx(FALSE,TRUE);
                width_mainframe = rc_mainframe.right - rc_mainframe.left;
                height_mainframe = rc_mainframe.bottom - rc_mainframe.top;
            end
            if width_mainframe <= 0 or height_mainframe <= 0 then
                base_utility.log(
                "[wg_frame_bottom_view]mainframe size is error, delay:"..tostring(allow_delay_set),
                                                                                             true);
                if allow_delay_set then
                    base_utility.add_interval("wg_frame_bottom_view.delay_set_bottom_bar_position", 
                                                300);
                end
                return;
            end

            local rc = pBtmDlg:GetRectEx(FALSE,TRUE);
            rc.left = 1; --wg_frame_bottom_view.mainframe_banner_list_width + 1;
            rc.right = width_mainframe - 1;
            rc.top = height_mainframe - wg_frame_bottom_view.BOTTOM_BAR_HEIGHT - 1;
            rc.bottom = rc.top + wg_frame_bottom_view.BOTTOM_BAR_HEIGHT; 
            pBtmDlg:MoveEx(rc,TRUE);
            -- 设置底栏bottom_content_pnl的宽度
            local bottom_content_id = ui_utility.get_ctrl_id_by_path(
                                        wg_frame_bottom_view.bottom_dlg_id_, "FrameBottomCtn_Pnl");
            ui_utility.setproperty_by_id(bottom_content_id, 'XOffset', '0');
            ui_utility.setproperty_by_id(bottom_content_id, 'Width', tostring(rc.right - rc.left));
        end
    end;

    delay_set_bottom_bar_position = function()
         base_utility.remove_interval("wg_frame_bottom_view.delay_set_bottom_bar_position");
         wg_frame_bottom_view.set_bottom_bar_position(false);   -- 防止多次设置
     end;

    switch_banner_helper = function(game_id)
        if wg_frame_bottom_view.game_id_ == game_id then
            return;
        end;
        wg_frame_bottom_view.game_id_ = game_id;
        local base_info = banner_model.get_game_base_info(game_id);
        if base_info == nil then   
            return;
        end;
        wg_frame_bottom_view.game_main_type_ = base_info.main_type;

        -- helper_area
        wg_frame_bottom_view.refresh_helper_area();

        progress_node_tips_area.hide_progress_node();
    end;

    -- 更新左侧按钮区状态
    refresh_helper_area = function()
        ui_utility.setproperty_by_id(
                                    wg_frame_bottom_view.bottom_helper_area_id_, "Visible", "true");
        helper_area.init_area(wg_frame_bottom_view.bottom_helper_area_id_, 
                              wg_frame_bottom_view.game_id_,
                              wg_frame_bottom_view.game_main_type_);
    end;
    
    -- 更新游戏或插件状态
    update_game_or_plugin_state = function(param_tbl)
        if param_tbl == nil then
            return;
        end;
        wg_frame_bottom_view.game_and_plugin_state_tbl_ = param_tbl;

        if frame_bottom_model.show_new_frame_bottom_ == true then
            wg_frame_bottom_view.refresh_bottom_status(param_tbl.game);
        end;
    end;
    
    -- 刷新底栏状态
    refresh_bottom_status = function(game_state_param)
        wg_frame_bottom_view.refresh_main_status(game_state_param);
        wg_frame_bottom_view.refresh_extension_status(game_state_param);
        helper_area.on_game_state_update(game_state_param.status);
    end;

    -- 刷新右侧按钮状态
    refresh_main_status = function(game_state_param)
        if game_state_param == nil then return end
        local game_id = game_state_param.game_id;
        local state_value = game_state_param.status;
        local sub_state_value = game_state_param.sub_status;

        local ext_state = game_state_param.extension_game_state.iState;
        local ext_sub_state = game_state_param.extension_game_state.iSub_state;
        
        wg_frame_bottom_view.inner_log(
            string.format("refresh_main_status:%d, %d", state_value, sub_state_value));

        if ierd_tgp.game_library.GAME_STATE_NORMAL == state_value or 
            ierd_tgp.game_library.GAME_STATE_UNKNOWN == state_value then
            -- 可运行
            local enable = true;
            if ext_state == ierd_tgp.game_library.GAME_STATE_INSTALLING then
                -- 扩展包安装的时候，不能启动
                enable = false;
            end;
            operate_area.refresh_operate_btn_status(
                            ierd_tgp.game_library.GAME_STATE_NORMAL, enable);
        elseif ierd_tgp.game_library.GAME_STATE_LAUNCHING == state_value then
            -- 启动中
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_RUNNING == state_value then
            -- 运行中
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_SERVER_UNAVAILABLE == state_value then
            -- 服务器维护
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_UNINSTALLING == state_value then
            -- 卸载中
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_NEED_UPDATE == state_value then
            -- 需要更新
            local pause_status = 0;
            local update_progress = 0;
            pause_status, update_progress = 
                                        frame_bottom_model.get_game_update_pause_status(game_id);
            if 0 ~= pause_status then
                -- 更新暂停
                local menu_bg = "ONEIMAGE:bottom_bar\\with_menu\\update_paused.png;Stretch;0;";
                local nomenu_bg = "ONEIMAGE:bottom_bar\\update_paused.png;Stretch;0;";
                operate_area.refresh_operate_btn_status(
                        ierd_tgp.game_library.GAME_STATE_UPDATE_PAUSED, false, menu_bg, nomenu_bg);   
            else
                -- 需要更新
                operate_area.refresh_operate_btn_status(state_value);
            end
        elseif ierd_tgp.game_library.GAME_STATE_BROKEN == state_value then
            if sub_state_value == 1 then  -- 支持重新下载
                operate_area.refresh_operate_btn_status(state_value);
            else  -- 显示未开放
                local menu_bg = "ONEIMAGE:bottom_bar\\with_menu\\inaccessible.png;Stretch;0;";
                local nomenu_bg = "ONEIMAGE:bottom_bar\\inaccessible.png;Stretch;0;";
                operate_area.refresh_operate_btn_status(state_value, false, menu_bg, nomenu_bg);
            end
        elseif ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL == state_value then
            -- 更新失败
            operate_area.refresh_operate_btn_status(state_value);
        elseif ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED == state_value then
            -- 未安装
            operate_area.refresh_operate_btn_status(state_value);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOADED == state_value then
            -- 下载完成
            operate_area.refresh_operate_btn_status(state_value);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL == state_value then
            -- 下载失败
            operate_area.refresh_operate_btn_status(state_value);
        elseif ierd_tgp.game_library.GAME_STATE_INSTALLING == state_value then  
            -- 安装中
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_SELECTING_SERVER == state_value then
            -- 正在选区
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOADING == state_value then
            -- 正在下载
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOAD_PAUSED == state_value then
            -- 下载暂停
            operate_area.refresh_operate_btn_status(state_value, false);
        elseif ierd_tgp.game_library.GAME_STATE_UPDATING == state_value then  
            -- 正在更新
            operate_area.refresh_operate_btn_status(state_value, false);
        end;
    end;

    -- 刷新extension状态
    refresh_extension_status = function(game_state_param)
        if game_state_param == nil then return end
        local game_id = game_state_param.game_id;
        local state_value = game_state_param.status;
        local sub_state_value = game_state_param.sub_status;

        local ext_state = game_state_param.extension_game_state.iState;
        local ext_sub_state = game_state_param.extension_game_state.iSub_state;

        local fSpeed = game_state_param.speed;
        local fProcess = game_state_param.progress;
        local fRemain_time = game_state_param.left_time;
        local errMsg = game_state_param.msg;
        local support_silent_install = game_state_param.silent_install;
        local install_mode = game_state_param.install_mode;

        wg_frame_bottom_view.inner_log(
            string.format("refresh_extension_status:%d, %d, %f", ext_state, ext_sub_state, fProcess));

        if ierd_tgp.game_library.GAME_STATE_NORMAL == ext_state or 
            ierd_tgp.game_library.GAME_STATE_UNKNOWN == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_LAUNCHING == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_RUNNING == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_SERVER_UNAVAILABLE == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_UNINSTALLING == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_NEED_UPDATE == ext_state then
            local pause_status = 0;
            local update_progress = 0;
            pause_status, update_progress = 
                                        frame_bottom_model.get_game_update_pause_status(game_id);
            if 0 ~= pause_status then
                if fProcess < update_progress then
                   fProcess = update_progress;
                end
                local status_txt = string.format("%s %.2f%%", LoadStr(ID_UPDATE_PAUSED), fProcess);
                downloading_area.set_update_pause_status(game_id, status_txt, fProcess);   
            else
                if state_value == ierd_tgp.game_library.GAME_STATE_NORMAL then
                    local status_txt = string.format("%s", LoadStr(ID_UPDATE_PAUSED));
                    downloading_area.set_update_pause_status(game_id, status_txt, 0); 
                else
                    downloading_area.show_area(false);
                end;
            end
        elseif ierd_tgp.game_library.GAME_STATE_BROKEN == ext_state then
            if ext_sub_state == 1 then  -- 支持重新下载
                downloading_area.set_error_prompt_txt(LoadStr(ID_BT_GAME_INVALID_VER), 
                                                        ierd_tgp.game_library.GAME_STATE_BROKEN);
            else
                downloading_area.set_error_prompt_txt(LoadStr(ID_BT_GAME_NOTSUPPORT));
            end
        elseif ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL == ext_state then
            local msgText = LoadStr(ID_BT_GAME_UPDATEFAIL);
            if errMsg ~= nil and errMsg ~= "" then
                msgText = errMsg;
            end
            downloading_area.set_error_prompt_txt(msgText, 
                                                    ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL);
        elseif ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOADED == ext_state then
            downloading_area.set_error_prompt_txt(LoadStr(ID_BT_DOWNLAOD_DONE), ext_state);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL == ext_state then
            local msgText = LoadStr(ID_BT_DOWNLOADFAIL);
            if errMsg ~= nil and errMsg ~= "" then
                msgText = errMsg;
            end
            downloading_area.set_error_prompt_txt(msgText, ext_state);
        elseif ierd_tgp.game_library.GAME_STATE_INSTALLING == ext_state then  -- 安装中
            downloading_area.set_installing_status(game_id, fProcess, support_silent_install, 
                                                    install_mode, game_state_param.custom_text);
        elseif ierd_tgp.game_library.GAME_STATE_SELECTING_SERVER == ext_state then
            downloading_area.show_area(false);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOADING == ext_state then  -- 下载中
            -- 设置进度文本
            local status_txt = '';
            local time_left = '';
            local use_tinysetup = frame_bottom_model.get_game_install_mode(game_id);
            if use_tinysetup == 1 then
                show_detail, status_txt, time_left = 
                                state_operation_panel.get_tinysetup_downloading_status_text(
                                ext_sub_state, fProcess);
            else
                status_txt = state_operation_panel.get_downloading_status_text(
                                ext_sub_state, fProcess);
            end
            
            -- 设置速度和剩余时间
            local speed_txt, remain_time_txt = downloading_area.get_speed_remain_time(
                                                    fSpeed, fRemain_time);
            if ierd_tgp.game_library.GAME_DOWNLOAD_WAIT == ext_sub_state or 
                ierd_tgp.game_library.GAME_DOWNLOAD_INIT == ext_sub_state then
                -- 等待下载状态不显示速度和时间
                speed_txt = "";
                remain_time_txt = "";
            end
            if show_detail then
                -- 显示详细状态不显示速度和时间
               speed_txt = "";
               remain_time_txt = "";
            end

            -- 优先显示下载器算出的倒计时
            if time_left ~= nil and time_left ~= "" then
                if fSpeed ~= nil and 0 ~= fSpeed then
                    speed_txt = string.format("%s", state_operation_panel.format_speed(fSpeed));
                end
                remain_time_txt = time_left;
            end

            local show_installing = false;
            -- 基础包安装时，底层的状态为下载中，这里修正一下展示文本
            if state_value == ierd_tgp.game_library.GAME_STATE_INSTALLING then
                show_installing = true;
            end;

            if show_installing then
                downloading_area.set_installing_status(game_id, fProcess, support_silent_install, 
                                                    install_mode, game_state_param.custom_text);
            else
                downloading_area.set_downloading_status(
                                        fProcess, status_txt, speed_txt, remain_time_txt, game_id);
            end

            -- 检测是否需要显示提示tips
            progress_node_tips_area.check_should_show_all_tips();
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOAD_PAUSED == ext_state then
            local status_txt = string.format("%s %.2f%%", LoadStr("FRAME_BOTTOM_DOWNLOADPAUSE"),
                fProcess);
            downloading_area.set_download_pause_status(game_id, status_txt, fProcess);
        elseif ierd_tgp.game_library.GAME_STATE_UPDATING == ext_state then  -- 正在更新
            local patch_name = "";
            if nil ~= cur_patch_name then
                patch_name = cur_patch_name;
                if state_operation_panel.is_english_ver then 
                    if string.len(patch_name) > 6 then
                        patch_name = " " .. string.sub(patch_name, 0, 6);
                    end
                else
                    if string.len(patch_name) > 7 then
                        patch_name = string.sub(patch_name, 0, 7);
                    end
                end
            end

            local pause_status = 0;
            local update_progress = 0;
            pause_status, update_progress = 
                                        frame_bottom_model.get_game_update_pause_status(game_id);
            local show_progress = fProcess;
            if 0 ~= pause_status then
                if fProcess < update_progress then
                    show_progress = update_progress;
                end
            end

            base_utility.log(string.format("fprocess:%d, show_progress:%d, update_progress:%d", 
                                            fProcess, show_progress, update_progress));

            local show_detail = false;
            local status_txt = state_operation_panel.get_updating_status_text(
                                                        ext_sub_state, show_progress, patch_name);
            local time_left = "";

            local external_update = state_operation_panel.is_external_update(game_id);
            if external_update == 1 then
                status_txt = state_operation_panel.get_external_updating_status_text(
                                                        ext_sub_state, show_progress, patch_name);
            end

            if ierd_tgp.game_library.GAME_UPDATE_DEPOT_INIT == ext_sub_state or 
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_WAIT == ext_sub_state or
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_DOWNLOAD == ext_sub_state or
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_INSTALL == ext_sub_state then
                show_detail, status_txt, time_left = 
                                        state_operation_panel.get_tinysetup_updating_status_text(
                                        ext_sub_state, show_progress);
            end

            -- 设置速度和剩余时间
            local speed_txt, remain_time = downloading_area.get_speed_remain_time(
                                                                            fSpeed, fRemain_time);
            if ierd_tgp.game_library.GAME_UPDATE_DOWNLOAD ~= ext_sub_state and 
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_DOWNLOAD ~= ext_sub_state then
                -- 非下载的场景下都不显示速度
                speed_txt = "";
                remain_time = "";
            end
            if show_detail then
                -- 显示详细信息的场景下都不显示速度
                speed_txt = "";
                remain_time = "";
            end

            -- 优先显示下载器算出的倒计时
            if time_left ~= nil and time_left ~= "" then
                if fSpeed ~= nil and 0 ~= fSpeed then
                    speed_txt = string.format("%s", state_operation_panel.format_speed(fSpeed));
                end
                remain_time = time_left;
            end

            downloading_area.set_updating_status(game_id, show_progress, status_txt, 
                                                speed_txt, remain_time);
        
            -- 检测是否需要显示提示tips
            progress_node_tips_area.check_should_show_all_tips();
        end;
    end;

    on_refresh_operate_menu = function()
        operate_area.refresh_menu_entry_status();
    end;

    handle_progress_node_layout = function(event_id, json_str)
        if progress_node_tips_area ~= nil then
            progress_node_tips_area.handle_progress_node_layout(event_id, json_str);
        end;
    end;

    on_mainframe_position_change = function()
        if progress_node_tips_area ~= nil then
            progress_node_tips_area.on_mainframe_position_change(wg_frame_bottom_view.game_id_);
        end;
    end;
    
    -- 带菜单入口的start按钮是否可见
    is_operate_menu_state_visible = function()
        if wg_frame_bottom_view.is_visible() == false then
            return false;
        end;
        return operate_area.is_menu_state_btn_visible();
    end;

    handle_simulate_click_right_button = function (data)
        if nil == data or nil == data.game_id then
            return;
        end

        if wg_frame_bottom_view.is_visible() == false then
            return;
        end;

        frame_bottom_view.on_right_btn_click();
    end;

    on_game_protocol_update_suc = function()
        if wg_frame_bottom_view.game_and_plugin_state_tbl_ == nil or 
           wg_frame_bottom_view.game_and_plugin_state_tbl_.game == nil then
            return;
        end;
        local game_state = wg_frame_bottom_view.game_and_plugin_state_tbl_.game.status;
        operate_area.refresh_normal_state_bg(game_state);
    end;

    on_color_mode_update = function(data)
        if nil == data or nil == data.color_mode then
            return;
        end
        base_utility.log("[wg_frame_bottom_view]on_color_mode_update: " .. tostring(data.color_mode), true);
        local color_mode = data.color_mode;
        
        wg_frame_bottom_view.color_text_ = "0xA4A4A4";
        if color_mode == MainCommon.color_mode.kLight then
            wg_frame_bottom_view.color_text_ = "0x3c3c3c";
        end;
        wg_frame_bottom_view.switch_color_mode(color_mode);
    end;

    switch_color_mode = function(color_mode)
        if wg_frame_bottom_view.is_visible() == false then
            return;
        end;
        base_utility.log("[wg_frame_bottom_view]switch_color_mode: " .. tostring(color_mode), true);
        -- TODO(amadeusyu): change tpf style
        local mainframe_id = ui_utility.get_ctrl_id_by_cid(CID_MAINFRAME_Dialog_MainFrame);
        if mainframe_id == nil then
            return;
        end;
        local bottom_dlg_id = ui_utility.get_ctrl_id_by_path(mainframe_id,
                           "pnlClient\\Ctn_BottomBar\\Dlg_Bottom");
         if bottom_dlg_id == nil then
            base_utility.log("[wg_frame_bottom_view]switch_color_mode no dlg_bottom", true);
            return;
         end;
        local bottom_dlg_ptr = ui_utility.get_ctrl_ptr_by_id(bottom_dlg_id);
        local uilib = ui_utility.uilib();
        if bottom_dlg_ptr == nil or uilib == nil then
            base_utility.log("[wg_frame_bottom_view]switch_color_mode no dlg_bottom ptr", true);
            return;
        end;
        local sText;
        if color_mode == MainCommon.color_mode.kLight then
            sText = U8toCUIStr("light");
        else
            sText = U8toCUIStr("dark");
        end;
        uilib:ChangeSkinMode(sText);

        local downloading_area_ctn_id = ui_utility.get_ctrl_id_by_path(
                           wg_frame_bottom_view.bottom_downLoading_area_id_, "DownLoadingAreaCtn");
        ui_utility.setproperty_by_path(downloading_area_ctn_id,
            "Cnt_Right\\ProgressCtn\\Ctn_Info_Area\\status_txt", 
            "TextColor", wg_frame_bottom_view.res_cfg_.DOWNLOADING_TXT_COLOR);

        ui_utility.setproperty_by_path(downloading_area_ctn_id, 
            "Cnt_Right\\ProgressCtn\\Ctn_Info_Area\\speed_txt", 
            "TextColor", 
            wg_frame_bottom_view.res_cfg_.DOWNLOADING_TXT_COLOR);

        ui_utility.setproperty_by_path(downloading_area_ctn_id, 
            "Cnt_Right\\ProgressCtn\\Ctn_Info_Area\\remain_time_txt", 
            "TextColor", 
            wg_frame_bottom_view.res_cfg_.DOWNLOADING_TXT_COLOR);
    end;
};
